package cn.silver.module.configuration.bean;

import cn.silver.framework.core.utils.DateUtils;
import cn.silver.framework.core.validate.AddGroup;
import cn.silver.framework.core.validate.EditGroup;
import cn.silver.framework.mybatis.bean.BusBean;
import cn.silver.module.configuration.domain.SysParam;
import cn.silver.module.configuration.domain.SysSerial;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.github.linpeilie.annotations.AutoMapper;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.io.Serial;
import java.io.Serializable;
import java.util.Date;

/**
 * @author zhouxiaobo
 */
@Data
@NoArgsConstructor
@ExcelIgnoreUnannotated
@EqualsAndHashCode(callSuper = true)
@AutoMapper(target = SysSerial.class)
@Schema(name = "SerialBean", title = "参数配置对象")
public class SerialBean extends BusBean implements Serializable {
    @Serial
    private static final long serialVersionUID = 1L;
    /**
     * 业务编码
     */
    @Schema(title = "业务编码")
    @NotBlank(message = "业务编码不能为空", groups = {AddGroup.class, EditGroup.class})
    private String busCode;
    /**
     * 序列号前缀
     */
    @Schema(title = "序列号前缀")
    @NotBlank(message = "序列号前缀不能为空", groups = {AddGroup.class, EditGroup.class})
    private String prefix;
    /**
     * 生成周期
     */
    @Schema(title = "生成周期")
    @NotBlank(message = "生成周期不能为空", groups = {AddGroup.class, EditGroup.class})
    private String format;
    /**
     * 数据域表达式
     */
    @Schema(title = "数据域表达式")
    @NotBlank(message = "数据域表达式不能为空", groups = {AddGroup.class, EditGroup.class})
    private String expression;
    /**
     * 序列号模板
     */
    @Schema(title = "序列号模板")
    @NotBlank(message = "序列号模板不能为空", groups = {AddGroup.class, EditGroup.class})
    private String template;
    /**
     * 最新生成的序列号
     */
    @Schema(title = "最新生成的序列号")
    private Integer lastNum;
    /**
     * 最新生成时间
     */
    @Schema(title = "最新生成时间")
    @JsonFormat(timezone = DateUtils.TIME_ZONE, pattern = DateUtils.YYYY_MM_DD)
    private Date lastTime;
    /**
     * 启用/禁用
     */
    @Schema(title = "启用/禁用")
    private Boolean enable;
}
